import request from './request'

// 获取角色列表
export const getRoleList = (params) => {
  return request.get('/role/list', { params })
}

// 获取角色详情
export const getRoleDetail = (id) => {
  return request.get(`/role/${id}`)
}

// 创建角色
export const createRole = (data) => {
  return request.post('/role', data)
}

// 更新角色信息
export const updateRole = (id, data) => {
  return request.put(`/role/${id}`, data)
}

// 删除角色
export const deleteRole = (id) => {
  return request.delete(`/role/${id}`)
}

// 批量删除角色
export const batchDeleteRoles = (ids) => {
  return request.delete('/role/batch', { data: { ids } })
}

// 启用/禁用角色
export const toggleRoleStatus = (id, status) => {
  return request.put(`/role/${id}/status`, { status })
}

// 获取权限列表
export const getPermissionList = () => {
  return request.get('/role/permissions')
}

// 分配角色权限
export const assignRolePermissions = (roleId, permissionIds) => {
  return request.put(`/role/${roleId}/permissions`, { permissionIds })
}
